<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>销售单信息表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="../common/layui/css/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="../common/bootstrap/css/bootstrap.css" media="all">
    <link rel="stylesheet" type="text/css" href="../common/global.css" media="all">
    <link rel="stylesheet" type="text/css" href="../css/personal.css" media="all">
</head>
<body>

<section class="layui-larry-box">


    <div class="larry-personal">
        <div class="layui-tab">
            <blockquote class="layui-elem-quote news_search">

                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <input id="sell_text1" value="" placeholder="请输入关键字" class="layui-input search_input" type="text">
                    </div>

                    <a class="layui-btn search_btn1" id="search_btn1">查询</a>
                </div>
                <div class="layui-inline">
                    <a class="layui-btn layui-btn-normal addsell"  id="addsell">添加销售单</a>
                </div>


                <div class="layui-inline">
                    <a class=" layui-btn recommend " id="print()"  onclick="toprint()">打印页面</a>
                </div>

                <div class="layui-inline">
                    <a class="layui-btn layui-btn-danger batchDel" onclick="toremoveall()">批量删除</a>
                </div>
                <div class="layui-inline">
                    <div class="layui-form-mid layui-word-aux">本页面刷新后除新添加的文章外所有操作无效，关闭页面所有数据重置</div>
                </div>
            </blockquote>

            <!-- 操作日志 -->
            <div class="layui-form news_list">
                <table class="layui-table" id="employee_list">
                    <colgroup>
                        <col width="50">
                        <col width="15%">
                        <col width="25%">
                        <col width="15%">
                        <col width="15%">
                        <col width="15%">
                        <col width="15%">
                        <col width="10%">
                    </colgroup>
                    <thead>
                    <tr>
						<th id="qxh1"><input name="" lay-skin="primary" lay-filter="allChoose" id="allChoose" type="checkbox">
							<div class="layui-unselect layui-form-checkbox" lay-skin="primary" onclick="toaler()">
								<i class="layui-icon"></i>
							</div>
						</th>
                        <th style="text-align:center;width: 120px ">单号</th>
                        <th>时间</th>
                        <th>价格</th>
                        <th>负责人</th>
                        <th>备注</th>
                        <th>操作</th>
                    </tr>

                    </thead>

                    <tbody class="news_content" id="cxtable">
                    <!--销售单列表区域-->


                    </tbody>
                </table>
            </div>
        </div>
    </div>

</section>
<script type="text/javascript" src="../common/layui/layui.js"></script>
<script src="../jsplug/jquery-1.8.3.min.js"></script>
<script src="../js/token.js"></script>
<script src="js/sell_table.js"></script>
<script type="text/javascript">

    //页面打印实现
    function toprint(){
        window.print();
    }


    //一进页面开始查询全体供货商信息
    $(function () {
        $.post("/sell/toseeksell", function (res) {
            //循环遍历出所有单号的信息
            var str = "";
            for (i = 0; i < res.data.length; i++) {
                str += "<tr>\n" +
                    "\t\t\t\t\t\t\t<td><input name=\"checked\" lay-skin=\"primary\" lay-filter=\"choose\" type=\"checkbox\" value='" + res.data[i].id + "'>\n" +
                    "\t\t\t\t\t\t\t\t<div class=\"layui-unselect layui-form-checkbox\" lay-skin=\"primary\"><i class=\"layui-icon\"></i></div>\n" +
                    "\t\t\t\t\t\t\t</td>"
                str += "<td align=\"center\">" + res.data[i].odd + "</td>";
                str += "<td>" +new Date(res.data[i].selltime).toLocaleString() + "</td>";
                str += "<td>" + res.data[i].sumprice + "</td>";
                str += "<td>" + res.data[i].principal + "</td>";
                str += "<td>" + res.data[i].remark + "</td>";
                str += "<td>\n" +
                    "\t\t\t\t\t\t\t<a class=\"layui-btn layui-btn-mini news_edit\" onclick=\"toupdate(" + res.data[i].id + ")\"><i class=\"iconfont icon-edit\"></i> 编辑</a>\n" +
                    "\t\t\t\t\t\t\t<a class=\"layui-btn layui-btn-danger layui-btn-mini news_del\" data-id=\"6\" onclick=\"toremove(" + res.data[i].id + ")\"><i class=\"layui-icon\"></i> 删除</a>\n" +
                    "\t\t\t\t\t\t</td>";

                layui.use(['form', 'upload'], function () {
                    var form = layui.form();
                    form.render();
                })
            }
            $("#cxtable").append(str);


        }, "json")

    });


    //编辑员工信息(将参数传递过去)

    function toupdate(id) {
        location.assign("updatesell.html?id=" + id);

    }


    //直接删除员工
    function toremove(id) {
        $.post("/sell/toremove", {id: id}, function (res) {
            layer.confirm('供货商删除成功，前往查看！', {
                icon: 1,        //会出现正确的图片
                btn: ['好']     //按钮
            }, function () {
                window.location.href = "sellform_table.html";//点击“好”后进行跳转
            });
        }, "json")
    }


    //一键删除勾选供货商
    function toremoveall() {
        var x = document.getElementsByName("checked");
        for (var i = 0; i < x.length; i++) {
            //拿到当前员工的id
            if (x[i].checked == true) {
                var emid = x[i].value;
                toremove(emid);
            }
        }
        layer.confirm('一键删除成功', {
            icon: 1,        //会出现正确的图片
            btn: ['好']     //按钮
        }, function () {
            window.location.href = "sellform_table.html";//点击“好”后进行跳转
        });
    }

</script>
</body>
</html>